class Component:
  Name = input("请输入你的姓名：")
  Age = input("请输入你的年龄：")
  ID = input("请输入你的身份证号码:")

  def __init__(self, name=Name, age=Age, id=ID):
    self.name = name
    self.age = age
    self.id = id

  def init(self):
      pass
      print("初始化中...")

  def doSelfTest(self):
      pass
      print("自检")



class Keyboard(Component):
  def getSelectedKey(self):
      pass
      print("获取按键值")


class ActionKeyboard(Keyboard):
  def getAction(self):
    print("将继续或者取消购票")


class TicketKindKeyboard(Keyboard):
  def getTicketKind(self):
    print("正在查询车票信息")


class DestinationKeyboard(Keyboard):
  def getDestinationCode(self):
    print("正在查询目的地信息")


class Screen(Component):
  def showText(self):
    print("正在显示车票详细信息")


class CardDriver(Component):
  def getCredit(self):
    print("已支付车票费用")

  def debitFare(self):
    print("卡的余额已更新")

  def ejectMCard(self):
    print("退卡成功")


class CashSlot(Component):
  def getCredit(self):
    print("已收到支付的钱")


class Printer(Component):
  def printTicket(self):
    print("正在打印车票\nage:{}\nid:{}")

  def ejectTicket(self):
    print("正在出票")

class TicketSoldSystem():
  def __init__(self):
    self.ActionKeyboard = ActionKeyboard()
    self.TicketKindKeyboard = TicketKindKeyboard()
    self.DestinationKeyboard = DestinationKeyboard()
    self.Screen = Screen()
    self.CardDriver = CardDriver()
    self.CashSlot = CashSlot()
    self.Printer = Printer()

  def verifyCredit(self):
    print("验证金额")

  def calculateFare(self):
    self.DestinationKeyboard.getDestinationCode()
    self.DestinationKeyboard.getSelectedKey()
    self.TicketKindKeyboard.getTicketKind()
    self.Screen.showText()
    print("您的车票费用为xx元")
    pay = input("请问是否支付: 1.支付 2.不支付")
    if int(pay) == 1:
      self.CardDriver.getCredit()  # 从卡里获取金额
      self.CardDriver.debitFare()  # 更新获取金额后卡的余额
      self.Printer.printTicket()  # 打印车票
      self.Printer.ejectTicket()  # 出票
      self.CardDriver.ejectMCard()  # 退卡
    else:
      self.CardDriver.ejectMCard()  # 退卡






Ticket = TicketSoldSystem()
Ticket.calculateFare()















